package com.unknown.common.countDownTimer;

import android.os.CountDownTimer;

import com.unknown.common.function.EEFunction;
import com.unknown.common.function.SEFunction;

class CountDownTimerManager extends CountDownTimer implements CountDownTimerService {
    private SEFunction<Long> onTick;
    private EEFunction onFinish;

    CountDownTimerManager(long millisInFuture, long countDownInterval, SEFunction<Long> onTick, EEFunction onFinish) {
        super(millisInFuture, countDownInterval);
        this.onTick = onTick;
        this.onFinish = onFinish;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        onTick.apply(millisUntilFinished);
    }

    @Override
    public void onFinish() {
        onFinish.apply();
    }

    public void startService() {
        start();
    }
}
